package com.bigegg.employee.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.bigegg.employee.domain.ActivityBoothPost;
import com.bigegg.employee.service.IActivityBoothPostService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 招聘会展位职位Controller
 * 
 * @author sun
 * @date 2022-08-15
 */
@RestController
@RequestMapping("/activity/post")
public class ActivityBoothPostController extends BaseController
{
    @Autowired
    private IActivityBoothPostService activityBoothPostService;

    /**
     * 查询招聘会展位职位列表
     */
    @PreAuthorize("@ss.hasPermi('employee:post:list')")
    @GetMapping("/list")
    public TableDataInfo list(ActivityBoothPost activityBoothPost)
    {
        startPage();
        List<ActivityBoothPost> list = activityBoothPostService.selectActivityBoothPostList(activityBoothPost);
        return getDataTable(list);
    }

    /**
     * 导出招聘会展位职位列表
     */
    @PreAuthorize("@ss.hasPermi('employee:post:export')")
    @Log(title = "招聘会展位职位", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ActivityBoothPost activityBoothPost)
    {
        List<ActivityBoothPost> list = activityBoothPostService.selectActivityBoothPostList(activityBoothPost);
        ExcelUtil<ActivityBoothPost> util = new ExcelUtil<ActivityBoothPost>(ActivityBoothPost.class);
        util.exportExcel(response, list, "招聘会展位职位数据");
    }

    /**
     * 获取招聘会展位职位详细信息
     */
    @PreAuthorize("@ss.hasPermi('employee:post:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(activityBoothPostService.selectActivityBoothPostById(id));
    }

    /**
     * 新增招聘会展位职位
     */
    @PreAuthorize("@ss.hasPermi('employee:post:add')")
    @Log(title = "招聘会展位职位", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ActivityBoothPost activityBoothPost)
    {
        return toAjax(activityBoothPostService.insertActivityBoothPost(activityBoothPost));
    }

    /**
     * 修改招聘会展位职位
     */
    @PreAuthorize("@ss.hasPermi('employee:post:edit')")
    @Log(title = "招聘会展位职位", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ActivityBoothPost activityBoothPost)
    {
        return toAjax(activityBoothPostService.updateActivityBoothPost(activityBoothPost));
    }

    /**
     * 删除招聘会展位职位
     */
    @PreAuthorize("@ss.hasPermi('employee:post:remove')")
    @Log(title = "招聘会展位职位", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(activityBoothPostService.deleteActivityBoothPostByIds(ids));
    }
}
